package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.MobileNumber;
import com.thinkcube.edutainment.service.viewitem.MobileItem;
import com.thinkcube.edutainment.service.viewitem.MobileItem_;

@EBean
public class MobileNumberAdapter extends BaseAdapter {

	List<MobileNumber> mobileNumber;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		MobileItem mobileItem;
		if (convertView == null) {
			mobileItem = MobileItem_.build(context);
		} else {
			mobileItem = (MobileItem) convertView;
		}

		mobileItem.bind(getItem(position));

		return mobileItem;
	}

	public List<MobileNumber> getMobileNumber() {
		return mobileNumber;
	}

	public void setMobileNumber(List<MobileNumber> mobileNumber) {
		this.mobileNumber = mobileNumber;
	}

	@Override
	public int getCount() {
		return mobileNumber.size();
	}

	@Override
	public MobileNumber getItem(final int position) {
		return mobileNumber.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
